﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package scripting {
    import Classes.*;
    import Modules.bandits.*;
    import Display.MarketUI.*;

    public class ScriptingConditions {

        public function playerInExperiment(_arg1:Object):Boolean{
            var _local4:Array;
            var _local5:int;
            var _local6:String;
            var _local2:String = _arg1["experimentName"];
            var _local3:String = (_arg1["experimentVariant"]) ? _arg1["experimentVariant"] : "1";
            if (((_local2) && (_local3))){
                _local4 = _local3.split(",");
                _local5 = Global.experimentManager.getVariant(_local2);
                for each (_local6 in _local4) {
                    if (_local5 == parseInt(_local6)){
                        return (true);
                    };
                };
            };
            return (false);
        }
        public function playerPurchasedStarterPack(_arg1:Object):Boolean{
            var _local2 = (Global.experimentManager.getVariant("cv_starter_pack") > 0);
            return (((_local2) && (Global.player.getSeenFlag("purchased_starter_pack"))));
        }
        public function playerRequiredLevel(_arg1:Object):Boolean{
            var _local2:int = (_arg1.level) ? _arg1.level : 1;
            return ((Global.player.level >= _local2));
        }
        public function playerHasSeen(_arg1:Object):Boolean{
            var _local2:Boolean = ((((String(_arg1["checkSessionFlags"]) == "1")) || ((String(_arg1["checkSessionFlags"]) == "true")))) ? Global.player.getSeenSessionFlag(_arg1.flag) : false;
            return (((Global.player.getSeenFlag(_arg1.flag)) || (_local2)));
        }
        public function playerHasNotSeen(_arg1:Object):Boolean{
            if ((((String(_arg1["checkSessionFlags"]) == "1")) || ((String(_arg1["checkSessionFlags"]) == "true")))){
                if (((!(Global.player.getSeenFlag(_arg1.flag))) && (!(Global.player.getSeenSessionFlag(_arg1.flag))))){
                    return (true);
                };
                return (false);
            };
            return (!(Global.player.getSeenFlag(_arg1.flag)));
        }
        public function playerFlag(_arg1:Object):Boolean{
            if (_arg1.flag){
                return ((int(Global.player.getFlag(_arg1.flag).value) == int(_arg1.value)));
            };
            return (false);
        }
        public function playerCompletedQuest(_arg1:Object):Boolean{
            var _local2:String = _arg1.quest;
            return (Global.player.isQuestCompleted(_local2));
        }
        public function playerNotCompletedQuest(_arg1:Object):Boolean{
            var _local2:String = _arg1.quest;
            return (!(Global.player.isQuestCompleted(_local2)));
        }
        public function timeWithinRange(_arg1:Object):Boolean{
            var _local2:String = _arg1.startDate;
            var _local3:String = _arg1.endDate;
            return (TimestampEvents.isCurrentTimeBetweeenRange(_local2, _local3));
        }
        public function alwaysTrue(_arg1:Object=null):Boolean{
            return (true);
        }
        public function hasNoConstructionSite(_arg1:Object=null):Boolean{
            var _local3:ConstructionSite;
            var _local2:Array = Global.world.getObjectsByClass(ConstructionSite);
            for each (_local3 in _local2) {
                if (_local3.targetName == _arg1.targetName){
                    return (false);
                };
            };
            return (true);
        }
        public function checkPoliceStations(_arg1=null):Boolean{
            if (BanditUtil.getPoliceStationLevel() == 1){
                return (true);
            };
            return (false);
        }
        public function checkNoPoliceStations(_arg1=null):Boolean{
            var _local3:ConstructionSite;
            var _local2:Array = Global.world.getObjectsByClass(ConstructionSite);
            for each (_local3 in _local2) {
                if (_local3.targetName == "mun_policestation"){
                    return (false);
                };
            };
            if (BanditUtil.getPoliceStationLevel() == 0){
                return (true);
            };
            return (false);
        }
        public function checkPopulation(_arg1=null):Boolean{
            return (((Global.world.citySim.getPopulation() * Global.gameSettings.getInt("populationScale", 1)) >= int(_arg1.requiredPopulation)));
        }
        public function hasObjectOnGameBoard(_arg1=null):Boolean{
            if (_arg1.itemName){
                return ((Global.world.getObjectsByNames([_arg1.itemName]).length > 0));
            };
            return (false);
        }
        public function hasNotObjectOnGameBoard(_arg1=null):Boolean{
            return (!(this.hasOrIsBuildingObjectOnGameBoard(_arg1)));
        }
        public function hasOrIsBuildingObjectOnGameBoard(_arg1=null):Boolean{
            var _local3:ConstructionSite;
            if (this.hasObjectOnGameBoard(_arg1)){
                return (true);
            };
            var _local2:Array = Global.world.getObjectsByClass(ConstructionSite);
            for each (_local3 in _local2) {
                if (_local3.targetName == _arg1.itemName){
                    return (true);
                };
            };
            return (false);
        }
        public function doesNotHaveAndIsNotBuildingObjectOnGameBoard(_arg1=null):Boolean{
            return (!(this.hasOrIsBuildingObjectOnGameBoard(_arg1)));
        }
        public function canPurchaseItem(_arg1=null):Boolean{
            if (_arg1.itemName){
                return (!(BuyLogic.isLocked(Global.gameSettings.getItemByName(_arg1.itemName))));
            };
            return (false);
        }
        public function hasNoObjectOnGameBoard(_arg1=null):Boolean{
            if (_arg1.itemName){
                return ((Global.world.getObjectsByNames([_arg1.itemName]).length == 0));
            };
            return (false);
        }
        public function shouldSeeStarterPack(_arg1=null):Boolean{
            var _local2:int = (_arg1.experimentVariant) ? _arg1.experimentVariant : 1;
            var _local3 = (Global.experimentManager.getVariant("cv_starter_pack") == _local2);
            return ((((_local3 === true)) && ((Global.player.hasMadePurchase === false))));
        }

    }
}//package scripting 
